/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.quician.webapp.ejbs;

import com.quician.fifa.Equipo;
import com.quician.fifa.Grupo;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author quician
 */

@LocalBean
@Stateless
public class TeamManager {
    
    @PersistenceContext //Entity Manager
    private EntityManager em;
    
    public List<Equipo> getTeams(){
    
        try{
            Query q = em.createNamedQuery("Equipo.findAll"); 
            return (List<Equipo>)q.getResultList();
        }
        catch(Exception e){
            Logger.getLogger(GroupManager.class.getName()).log(Level.SEVERE,"Error al extraer los equipos",e); 
            return null;
        }
    }
    
}
